var SM = SM || {}
SM.YUILoader = function(){
	var callbacks = [];
	var yui_build_dir="/includes/js/ext/yui/build/";
	
	var loader = new YAHOO.util.YUILoader({
		
	    // Identify the components you want to load.  Loader will automatically identify
	    // any additional dependencies required for the specified components.
	    require: ["logger", "dom", "event", "element", "container", "connection", "json", "animation", "paginator", "datasource"],
	    base: yui_build_dir,

	    // Configure loader to pull in optional dependencies.  For example, animation
	    // is an optional dependency for slider.
	    loadOptional: true,

	    // The function to call when all script/css resources have been loaded
	    onSuccess: function() {
	        //this is your callback function; you can use
	        //this space to call all of your instantiation
	        //logic for the components you just loaded.
		var myLogReader = new YAHOO.widget.LogReader(document.body);
                execCallbacks();
	    },

	    // Configure the Get utility to timeout after 10 seconds for any given node insert
	    timeout: 10000,

	    // Combine YUI files into a single request (per file type) by using the Yahoo! CDN combo service.
	    combine: false
	});

	var registerCallback = function(callback){
            callbacks.push(callback);
	}

	var execCallbacks = function(){
            for(var i=0; i < callbacks.length; i++){
                if(YAHOO.lang.isFunction(callbacks[i])){
                    callbacks[i]();
                }
            }
	} 

	var init = function(){
            loader.insert();
	}

	return{
            registerCallback : registerCallback,
            init : init
	}
}();